//用户管理项目相关的接口函数
import request from '@/utils/request'

//获取主持的创建的项目列表
export const getProjectListByHostApi = (page, size) => {
    return request({
        url: `/project/host/${page}/${size}`,
        method: "get"
    })
}
//获取参与的项目列表
export const getProjectListByInvolvedApi = (page, size) => {
    return request({
        url: `/project/participate/${page}/${size}`,
        method: "get"
    })
}
//根据项目id查
export const getProjectByIdApi = id => {
    return request({
        url: `/project/${id}`,
        method: "get"
    })
}

//增项目
export const createProjectApi = data => {
    return request({
        url: `/project`,
        method: "post",
        data
    })
}


//删项目
export const deleteProjectApi = id => {
    return request({
        url: `/project/${id}`,
        method: "delete"
    })
}

//改项目
export const updateProjectApi = data => {
    return request({
        url: `/project/${data.id}`,
        method: "put",
        data
    })
}


//改Logo
export const updateProjectLogoFileApi = (id, file) => {
    return request.putForm(`/project/logo/${id}`, {file})
}

//根据id获取项目文件
export const getProjectFileById = projectId => {
    return request({
        url: `/project/file/${projectId}`,
        method: "get"
    })
}

//增文件
export const createProjectResourceFileApi = (id, file) => {
    console.log("上传的文件", file)
    return request.postForm(`/project/file/${id}`, {file})
}

//删文件
export const deleteProjectResourceFileApi = (id, path) => {
    return request({
        url: `/project/file/${id}`,
        method: "delete",
        params: {
            fileUrl: path
        }
    })
}

//申请指导老师修改
export const applyForProjectApi = projectId => {
    return request.put(`/project/applyFor/${projectId}`)
}

//指导老师不同意修改
export const upNoProjectApi = projectId => {
    return request.put(`/project/upNo/${projectId}`)
}

//指导老师同意修改
export const upOkProjectApi = projectId => {
    return request.put(`/project/upOk/${projectId}`)
}
